package com.wrial.face;
/*
 * @Author  Wrial
 * @Date Created in 19:17 2020/8/20
 * @Description
 */

import java.util.HashSet;
import java.util.Set;

public class Main {


    public static int[] delete(int[] nums){
        if(nums.length<=1) return nums;
        int[] temp = new int[nums.length];
        Set<Integer> set = new HashSet<>();
        int p = 0;
        for(int i=0;i<nums.length;i++){
            if(!set.contains(nums[i])){
                temp[p++] = nums[i];
                set.add(nums[i]);
            }
        }
        int[] ans = new int[p];
        for(int i=0;i<p;i++){
            ans[i] = temp[i];
        }
        return ans;
    }

    public static void main(String[] args) {
        int[] ints = delete(new int[]{1, 2, 5, 5, 8, 5, 6});
        for (int anInt : ints) {
            System.out.println(anInt);
        }
    }

}
